package io.datajek.springbasics.movierecommendersystem.Lesson9;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;

@Component
public class ContentBasedFilter implements Filter {
    //用于计数创建的实例
    private static int instances= 0;

//    @Autowired注解--定义依赖关系
    @Autowired
    private Movie movie;

    public ContentBasedFilter(Movie movie) {
        super();
        instances++;
        this.movie = movie;
        System.out.println("ContentBasedFilter constructor called");
    }

//    为依赖关系定义getter方法
    public Movie getMovie() {
        return movie;
    }

    public static int getInstances(){
        return ContentBasedFilter.instances;
    }

//Filter接口中方法的实现
    public String[] getRecommendations(String movie) {

        return new String[] {"Happy Feet", "Ice Age", "Shark Tale"};

    }
}
